package com.coffee.takeoutserver.service.impl;

import com.coffee.takeoutserver.bean.GoodsInfo;
import com.coffee.takeoutserver.bean.GoodsInfoExample;
import com.coffee.takeoutserver.bean.GoodsTypeInfo;
import com.coffee.takeoutserver.bean.GoodsTypeInfoExample;
import com.coffee.takeoutserver.dao.GoodsInfoMapper;
import com.coffee.takeoutserver.dao.GoodsTypeInfoMapper;
import com.coffee.takeoutserver.service.GoodsInfoService;
import com.coffee.takeoutserver.service.GoodsTypeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
class GoodsInfoServiceImpl implements GoodsInfoService {
    @Autowired
    private GoodsInfoMapper goodsInfoMapper;

    @Override
    public List<GoodsInfo> getGoodsInfoListBySellerId(int sellerId) {
        GoodsInfoExample goodsInfoExample = new GoodsInfoExample();
        goodsInfoExample.setOrderByClause("id desc");
        GoodsInfoExample.Criteria criteria = goodsInfoExample.createCriteria();
        criteria.andSelleridEqualTo(sellerId);
        return goodsInfoMapper.selectByExample(goodsInfoExample);
    }


    @Override
    public void deleteGoodsInfoById(int id) {
        goodsInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insertGoodsInfo(GoodsInfo goodsInfo) {
        goodsInfoMapper.insert(goodsInfo);
    }

    @Override
    public void updateGoodsInfoById(GoodsInfo goodsInfo) {
        goodsInfoMapper.updateByPrimaryKeySelective(goodsInfo);
    }
}
